<!DOCTYPE html>
<html>
<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">

    <title>活动查询</title>
    <base href="${rc.contextPath}/">
    <#include "/commons/stylesheets.ftl">
    <!-- Data Tables -->
    <link href="bootstrap-table/bootstrap-table.min.css" rel="stylesheet" />
    <link href="css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet" />
    <link href="css/plugins/chosen/chosen.css" rel="stylesheet" />
    <link href="css/plugins/switchery/switchery.css" rel="stylesheet" />
    <link href="/layer/skin/layer.css" rel="stylesheet">
    <style type="text/css">
        #toolbar button {
            margin-right: 10px;
        }
    </style>
    <script type="text/javascript">

        Date.prototype.format = function(format) {
               var date = {
                      "M+": this.getMonth() + 1,
                      "d+": this.getDate(),
                      "h+": this.getHours(),
                      "m+": this.getMinutes(),
                      "s+": this.getSeconds(),
                      "q+": Math.floor((this.getMonth() + 3) / 3),
                      "S+": this.getMilliseconds()
               };
               if (/(y+)/i.test(format)) {
                      format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
               }
               for (var k in date) {
                      if (new RegExp("(" + k + ")").test(format)) {
                             format = format.replace(RegExp.$1, RegExp.$1.length == 1
                                    ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
                      }
               }
               return format;
        }
        var ActivityStatus = {"1":"未开始","2":"活动中","3":"已结束"};
        //var Operation = {"1":"<a href='/activity/editActivity?id=activityId'>修改</a>&nbsp;&nbsp;<a href='javaScript:del(activityId)'>删除</a><br/><a href='/activity/getActivityDetail?id=activityId'>绑定用户</a>",
       //             "2":"<a href='/activity/getActivityView?id=activityId'>详情</a>&nbsp;&nbsp;<a href='/customerVehicle/getActivityCustomer?id=activityI'>参与人员</a>",
      //              "3":"<a href='/activity/getActivityView?id=activityId'>详情</a>&nbsp;&nbsp;<a href='/customerVehicle/getActivityCustomer?id=activityId'>参与人员</a>"
       //             };

           var Operation = {"1":"<div class=\"btn-group\"><button data-toggle=\"dropdown\" class=\"btn btn-primary btn-xs dropdown-toggle\">操作<span class=\"caret\"></span></button><ul class=\"dropdown-menu\"><li><a href=\"activity/editActivity?id=activityId\">修改</a></li><li><a href=\"javaScript:del(activityId);\">删除</a></li><li><a href=\"javaScript:openDialog('activity/getActivityDetail?id=activityId','绑定用户',1000,620);\">绑定用户</a></li></ul></div>",
                            "2":"<div class=\"btn-group\"><button data-toggle=\"dropdown\" class=\"btn btn-primary btn-xs dropdown-toggle\">操作<span class=\"caret\"></span></button><ul class=\"dropdown-menu\"><li><a href=\"javaScript:openDialog('activity/getActivityView?id=activityId','详情',800,520);\">详情</a></li><li><a href=\"javaScript:openDialog('customerVehicle/getActivityCustomer?id=activityId','参与人员',800,520);\">参与人员</a></li></ul></div>",
                            "3":"<div class=\"btn-group\"><button data-toggle=\"dropdown\" class=\"btn btn-primary btn-xs dropdown-toggle\">操作<span class=\"caret\"></span></button><ul class=\"dropdown-menu\"><li><a href=\"javaScript:openDialog('activity/getActivityView?id=activityId','详情',800,520);\">详情</a></li><li><a href=\"javaScript:openDialog('customerVehicle/getActivityCustomer?id=activityId','参与人员',800,520);\">参与人员</a></li></ul></div>"
                            };

        function formatOperation(value,row,index){
            var operationUrl = Operation[value] ;
            operationUrl = operationUrl.replace(/activityId/g, row.uuid.id);
            return operationUrl ;
        }

        function formatActivityStatus(value,row,index){
            return ActivityStatus[value]
        }

        function formatActivityTime(value,row,index){
            var endTime = row.endTime ;
            var startDate = new Date();
            var endDate = new Date();
            startDate.setTime(value);
            endDate.setTime(endTime);

            var activityTime = startDate.format('yyyy-MM-dd hh:mm:ss') + "至" + endDate.format('yyyy-MM-dd hh:mm:ss') ;
            return activityTime ;
        }

        function formatCompanyName(value,row,index){
            if(value) {
                value = value.replaceAll(',','<br/>');
            }
            return value;
        }



        function formatDate(value,row,index){
            var newDate = new Date();
            newDate.setTime(value);
            return newDate.format('yyyy-MM-dd hh:mm:ss');
        }

        function search(){
            $("#table").bootstrapTable("refresh",{url:"${rc.contextPath}/activity/queryActivityList?"+$("#form").serialize()});
        }

        function refreshTable(){
            $("#table").bootstrapTable("refresh");
        }

        function del(id){
            var handleResponse = function(resp){
                if (resp.resultCode == "success") {
                    refreshTable();
                    layer.msg('删除成功');
                } else {
                    layer.msg('删除失败');
                }
            };
            layer.confirm('确定要删除选择的记录吗?', {
                btn: ['确定','取消'] //按钮
            }, function(){
                $.ajax({
                    url:"activity/delActivity",traditional:true,data:{id:id},type:'post',success:handleResponse
                });
                layer.closeAll();
            });
    }
    </script>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>活动查询
                    </h5>
                </div>

                <div class="ibox-content">

                    <form  id="form" class="form-horizontal">
                        <div class="col-sm-12">
                            <div class="row">
                                <div class="form-group">
                                    <label class="col-sm-1 control-label">活动企业</label>

                                    <div class="col-sm-2">
                                        <input type="text" placeholder="活动企业" name="companyName" class="form-control">
                                    </div>

                                    <label class="col-sm-1 control-label">活动名称</label>

                                    <div class="col-sm-2">
                                        <input type="text" placeholder="活动名称" name="activityName" class="form-control">
                                    </div>

                                    <label class="col-sm-1 control-label">活动状态</label>

                                    <div class="col-sm-2">
                                        <select name="activityStatus" class="form-control" >
                                        <option value="">请选择</option>
                                        <option value="1">未开始</option>
                                        <option value="2">活动中</option>
                                        <option value="3">已结束</option>
                                    </select>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <div class="col-sm-12">
                            <div class="row">
                                <div class="form-group">
                                    <label class="col-sm-1 control-label">开始时间></label>

                                    <div class="col-sm-2">
                                        <input type="text"  class="form-control layer-date"  timeColumn="true" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" id="activityStartTime" name="activityStartTime"  />

                                    </div>

                                    <label class="col-sm-1 control-label">结束时间<</label>

                                    <div class="col-sm-2">
                                        <input type="text" class="form-control layer-date"   timeColumn="true" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss', minDate:'#F{$dp.$D(\'activityStartTime\',{H:1});}'})" id="activityEndTime" name="activityEndTime" />

                                    </div>

                                    <button class="btn btn-primary" type="button" style="margin-left: 20px;"  onclick="search()">
                                       <i class="fa fa-search"></i>
                                       &nbsp;查询
                                    </button>
                                </div>
                            </div>
                        </div>
                    </form>
                        <div id="toolbar">

                         </div>
                    <br/><br/>
                         <table id="table"
                            data-striped="true"
                            data-icons-prefix="fa"
                            data-toolbar="#toolbar"
                            data-data-field="list"
                            data-search="false"
                            data-show-refresh="false"
                            data-show-columns="false"
                            data-show-export="false"
                            data-side-pagination="server"
                            data-pagination="true"
                            data-page-size="15"
                            data-page-list="[10,15,20,30]"
                            data-url="${rc.contextPath}/activity/queryActivityList">
                            <thead>
                                <tr>
                                    <th data-checkbox="true" data-field="id">id</th>
                                    <th data-field="activityName">活动名称</th>
                                    <th data-field="companyNames" data-formatter="formatCompanyName">活动企业</th>
                                    <th data-field="activityDesc">活动内容</th>
                                    <th data-field="smsSendTime" data-formatter="formatDate">推送时间</th>
                                    <th data-field="startTime" data-formatter="formatActivityTime">活动时间</th>
                                    <th data-field="activityStatus" data-formatter="formatActivityStatus">活动状态</th>
                                    <th data-field="activityStatus" data-formatter="formatOperation" >操作</th>
                                </tr>
                            </thead>
                            <tbody>

                            </tbody>

                        </table>

                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 全局js -->
    <#include "/commons/scripts.ftl">
    <script src="/layer/layer.js"></script>
    <script src="/js/app.js"></script>

    <script type="text/javascript" src="/bootstrap-table/bootstrap-table.min.js"></script>
    <script type="text/javascript" src="/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <!-- WdatePickerr -->
    <script src="/js/plugins/My97DatePicker/WdatePicker.js"></script>
    <!-- Page-Level Scripts -->
    <script>
       $(function(){
            $("#table").bootstrapTable({locale:'zh-CN'})

       });

    </script>

    
    <!--统计代码，可删除-->

</body>

</html>